﻿using System.Net;
using WirelessAccessPoint.Core;
using WirelessAccessPoint.InteropServices;
using WirelessAccessPoint.Resources;

namespace WirelessAccessPoint.Model
{
    /// <summary>
    /// Hosted Networkに接続されているPeerを表します。
    /// </summary>
    public class HostedNetworkPeer : ModelBase
    {
        private string peerMacAddress;
        private IPAddress peerIPAddress;
        private WLAN_HOSTED_NETWORK_PEER_AUTH_STATE? peerAuthState;

        #region プロパティ

        /// <summary>
        /// MACアドレスを設定または取得します。
        /// </summary>
        public string PeerMacAddress
        {
            get { return this.peerMacAddress; }
            set
            {
                if (value != this.peerMacAddress)
                {
                    this.peerMacAddress = value;
                    this.OnPropertyChanged(() => this.PeerMacAddress);
                }
            }
        }

        /// <summary>
        /// IPアドレスを設定または取得します。
        /// </summary>
        public IPAddress PeerIPAddress
        {
            get { return this.peerIPAddress; }
            set
            {
                if (value != this.peerIPAddress)
                {
                    this.peerIPAddress = value;
                    this.OnPropertyChanged(() => this.PeerIPAddress);
                }
            }
        }

        /// <summary>
        /// 認証状態を設定または取得します。
        /// </summary>
        public WLAN_HOSTED_NETWORK_PEER_AUTH_STATE? PeerAuthState
        {
            get { return this.peerAuthState; }
            set
            {
                if (value != this.peerAuthState)
                {
                    this.peerAuthState = value;
                    this.OnPropertyChanged(() => this.PeerAuthState);
                    this.OnPropertyChanged(() => this.PeerAuthStateString);
                }
            }
        }

        #endregion

        #region 表示用プロパティ

        /// <summary>
        /// IPアドレスの文字列表現を取得します。
        /// </summary>
        public string PeerIPAddressString
        {
            get { return this.PeerIPAddress == null ? string.Empty : this.PeerIPAddress.ToString(); }
        }

        /// <summary>
        /// 認証状態の文字列表現を取得します。
        /// </summary>
        public string PeerAuthStateString
        {
            get { return this.PeerAuthState.ToLabel<WlanHostedNetworkPeerAuthStateResource>(); }
        }

        #endregion
    }
}
